package com.lonely.web.controller.production;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lonely.common.core.domain.StatusInfo;
import com.lonely.common.core.domain.api.R;
import com.lonely.product.domain.dto.cuttingbed.AlreadyLabelRackDTO;
import com.lonely.product.domain.dto.cuttingbed.QueryCuttingBedPageDTO;
import com.lonely.product.domain.dto.cuttingbed.StartCuttingDTO;
import com.lonely.product.domain.dto.cuttingbed.TypeInCuttingQuantitySubmitDTO;
import com.lonely.product.domain.vo.cuttingbed.QueryCuttingBedPageVO;
import com.lonely.product.domain.vo.cuttingbed.TypeInCuttingQuantityDetailVO;
import com.lonely.product.service.ICuttingBedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : 黄志标
 * @date: 2025/7/24 14:02
 * @description: 裁床请求处理器
 */
@RestController
@RequestMapping("/productionManager/cuttingBed")
@Api(tags = "生产管理/裁床管理")
public class CuttingBedController {

    @Autowired
    private ICuttingBedService cuttingBedService;

    /**
     * 分页查询
     *
     * @param queryDto
     * @return
     */
    @PostMapping("/page")
    @ApiOperation(value = "裁床分页查询")
    public R<Page<QueryCuttingBedPageVO>> page(@RequestBody @Validated QueryCuttingBedPageDTO queryDto) {
        return R.data(this.cuttingBedService.page(queryDto));
    }

    /**
     * 获取裁床管理状态信息
     *
     * @param queryDto
     * @return
     */
    @PostMapping("/getStatusInfo")
    public R<List<StatusInfo>> getStatusInfo(@RequestBody @Validated QueryCuttingBedPageDTO queryDto) {
        return R.data(this.cuttingBedService.getStatusInfo(queryDto));
    }

    /**
     * 已排唛架
     *
     * @param alreadyLabelRackDTO
     * @return
     */
    @PostMapping("/alreadyLabelRack")
    @SaCheckPermission("production:cuttingBed:alreadyLabelRack")
    public R<Boolean> alreadyLabelRack(@RequestBody @Validated AlreadyLabelRackDTO alreadyLabelRackDTO) {
        this.cuttingBedService.alreadyLabelRack(alreadyLabelRackDTO);
        return R.status(true);
    }

    /**
     * 开始裁床
     *
     * @param startCuttingDTO
     * @return
     */
    @PostMapping("/startCutting")
    @SaCheckPermission("production:cuttingBed:startCutting")
    public R<Boolean> startCutting(@RequestBody @Validated StartCuttingDTO startCuttingDTO) {
        this.cuttingBedService.startCutting(startCuttingDTO);
        return R.status(true);
    }

    /**
     * 查询录入裁床数详情数据
     *
     * @param cuttingId
     * @return
     */
    @GetMapping("/typeInCuttingQuantityDetail/{cuttingId}")
    public R<TypeInCuttingQuantityDetailVO> typeInCuttingQuantityDetail(@PathVariable("cuttingId") Long cuttingId) {
        return R.data(this.cuttingBedService.typeInCuttingQuantityDetail(cuttingId));
    }


    /**
     * 录入裁床数
     *
     * @param submitDto
     * @return
     */
    @PostMapping("/typeInCuttingQuantity")
    @SaCheckPermission("production:cuttingBed:typeInCuttingQuantity")
    public R<Boolean> typeInCuttingQuantity(@RequestBody @Validated TypeInCuttingQuantitySubmitDTO submitDto) {
        this.cuttingBedService.typeInCuttingQuantity(submitDto);
        return R.status(true);
    }


}
